
#ifndef BalanceType_H
#define BalanceType_H

#include <stdint.h>
#include <stdio.h>
#include <string>

class BalanceType
{
public:
  BalanceType ();
  BalanceType ( const BalanceType & ) ; // copy constructor


  void SetBalanceFromFloat ( float     newBalance );
  void SetBalanceFromInt   ( int32_t   newBalance );
  ~BalanceType();

//  BalanceType & operator+ (const BalanceType &rhs);
  BalanceType & operator+=(const BalanceType &rhs);
//  BalanceType & operator- (const BalanceType &rhs);
  BalanceType & operator-=(const BalanceType &rhs);
  
  // Converesion operator to get  the value of the balance.
  operator double () ;
  
  std::string GetValue () ;
  
  // Rouitines for test/debug
  void dump ( const char * temp ) const
  {
    
    printf ( "Balance : %s : %d\n", temp, mBalance ) ;
    
  }

private:
  int32_t  mBalance ; // avoid arithmetic errors, make all currency an integer

};

inline BalanceType operator+(BalanceType lhs, const BalanceType& rhs)
{
  lhs.dump ( "lhs" ) ;
  rhs.dump ( "rhs" ) ;
  lhs += rhs;
  lhs.dump ( "lhs result" ) ;
  return lhs;
} 

#endif
